import 'package:flutter/material.dart';
import 'package:flutter_elf/config/component_index.dart';
import 'package:flutter_elf/provider/global_provider.dart';
import 'package:provider/provider.dart';

class AppBarCreator{

  static PreferredSizeWidget create(context,String title,{Widget rightWidget,Color bacColor }){
    return PreferredSize(
        preferredSize: Size.fromHeight(50),
        child: AppBar(
          backgroundColor: Theme.of(context).primaryColor,
          title: Center(child: new Text(title)),
          centerTitle: true,
          leading: FlatButton(
              onPressed: () {
                Navigator.of(context).pop(false);
              },
              child: Icon(Icons.arrow_back,color: Colors.white,)),
          actions:rightWidget == null ? []: <Widget>[
            rightWidget,
            SizedBox(width: 10,)
          ],
        ),
//        child: Consumer<GlobalProvider>(
//          builder: (context,global,child){
//            return AppBar(
//              backgroundColor: global.getPrimaryColor(),
//              title: Center(child: new Text(title)),
//              centerTitle: true,
//              leading: FlatButton(
//                  onPressed: () {
//                    Navigator.of(context).pop(false);
//                  },
//                  child: Icon(Icons.arrow_back,color: Colors.white,)),
//              actions:rightWidget == null ? []: <Widget>[
//                rightWidget,
//                SizedBox(width: 10,)
//              ],
//            );
//          },
//        )
    );
  }

}